package com.gopay.common.riskcontrol.dao.impl;

import com.gopay.common.base.dao.impl.BaseReadDAOImpl;
import com.gopay.common.domain.dic.DicRclDirection;
import com.gopay.common.riskcontrol.dao.DicRclDirectionQueryDao;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import java.io.Serializable;
import java.util.List;

/**
 * Created by zhaojt on 2017/5/24.
 */
@Repository("dicRclDirectionQueryDao")
public class DicRclDirectionQueryDaoImpl extends BaseReadDAOImpl<DicRclDirection, Serializable> implements DicRclDirectionQueryDao {

    @Override
    public DicRclDirection find(String acctProd, String custType, String intTxnCd, String tranDirection) {
        DetachedCriteria criteria = DetachedCriteria.forClass(DicRclDirection.class);
        criteria.add(Restrictions.eq("acctProd", acctProd));
        criteria.add(Restrictions.eq("custType", custType));
        criteria.add(Restrictions.eq("intTxnCd", intTxnCd));
        criteria.add(Restrictions.eq("tranDirection", tranDirection));
        List<DicRclDirection> list = this.findByCriteria(criteria);
        return (list != null && list.size() > 0) ? list.get(0) : null;
    }
}
